package com.lancoo.edu.platform.operation.backupRestore.service.timer.job;


import com.lancoo.edu.platform.operation.backupRestore.service.init.BrServerSysInitService;
import com.lancoo.edu.platform.operation.backupRestore.service.timer.ScheduleTask;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * @author zhang.ws
 * @date 2024/6/21 17:17
 * @description 更新系统对应服务器IP任务
 */
@Slf4j
@AllArgsConstructor
public class UpdateServerSysIpJob implements Job {

    private final ScheduleTask scheduleTask;
    private final BrServerSysInitService brServerSysInitService;

    /**
     * 执行任务
     *
     * @param context 任务上下文
     * @throws JobExecutionException 任务执行异常
     */
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        // 1、获取触发器名（任务ID）
        String group = context.getTrigger().getKey().getGroup();
        String taskId = context.getTrigger().getKey().getName();
        if (scheduleTask.beExecute(group, taskId)) {
            return;
        }
        brServerSysInitService.saveServerSysIp();
        log.info("【更新系统对应服务器IP成功】");
    }
}
